<?php
@session_start();

$con = mysqli_connect("127.0.0.1","root","","posts");

$username = $_POST['username'];
$password = $_POST['password'];

$query = "select * from info where name='$username' and password='$password'";
$result=mysqli_query($con,$query);
if($result && mysqli_num_rows($result)){
    $_SESSION['user'] = $username;
    mysqli_close($con);
    echo "<script>window.location='../html/posts.html'</script>";
}else{
    mysqli_close($con);
    echo "<script>alert('invalid username or password');window.location='../html/login.html'</script>";
}

?>